]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageList: Use duration 0 when not animating
authorAlessandro Bono <alessandro.bono369@gmail.com>
Sun, 15 Jan 2023 12:12:18 +0000 (13:12 +0100)
committerMarge Bot <marge-bot@gnome.org>
Sat, 21 Oct 2023 15:02:55 +0000 (15:02 +0000)
Instead of using a special branch for the not animate case, just use
the same path with duration 0.

Since commit ee09c5c85312f571e14abe69bb6674a361c16d65 we are sure that
duration 0 is always preserved.

In the not animate case, we now call this._actionBin.hide(). This was not
happening before.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2987>

js/ui/messageList.js

index 5245b3fe92b9671da7def698834b973ba608ea23..c3746bc1cb86ed8e61da98afebfcc23083f5d85d 100644 (file)
@@ -481,47 +481,38 @@ export const Message = GObject.registerClass({
             this.setExpandedBody(this._expandedLabel);
         }
 
-        if (animate) {
-            this._bodyStack.ease_property('@layout.expansion', 1, {
-                progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-                duration: MessageTray.ANIMATION_TIME,
-            });
+        const duration = animate ? MessageTray.ANIMATION_TIME : 0;
+        this._bodyStack.ease_property('@layout.expansion', 1, {
+            progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            duration,
+        });
 
-            this._actionBin.scale_y = 0;
-            this._actionBin.ease({
-                scale_y: 1,
-                duration: MessageTray.ANIMATION_TIME,
-                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            });
-        } else {
-            this._bodyStack.layout_manager.expansion = 1;
-            this._actionBin.scale_y = 1;
-        }
+        this._actionBin.scale_y = 0;
+        this._actionBin.ease({
+            scale_y: 1,
+            duration,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
 
         this.emit('expanded');
     }
 
     unexpand(animate) {
-        if (animate) {
-            this._bodyStack.ease_property('@layout.expansion', 0, {
-                progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-                duration: MessageTray.ANIMATION_TIME,
-            });
+        const duration = animate ? MessageTray.ANIMATION_TIME : 0;
+        this._bodyStack.ease_property('@layout.expansion', 0, {
+            progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            duration,
+        });
 
-            this._actionBin.ease({
-                scale_y: 0,
-                duration: MessageTray.ANIMATION_TIME,
-                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-                onComplete: () => {
-                    this._actionBin.hide();
-                    this.expanded = false;
-                },
-            });
-        } else {
-            this._bodyStack.layout_manager.expansion = 0;
-            this._actionBin.scale_y = 0;
-            this.expanded = false;
-        }
+        this._actionBin.ease({
+            scale_y: 0,
+            duration,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => {
+                this._actionBin.hide();
+                this.expanded = false;
+            },
+        });
 
         this.emit('unexpanded');
     }
@@ -643,15 +634,14 @@ export const MessageListSection = GObject.registerClass({
 
         this._list.insert_child_at_index(listItem, index);
 
-        if (animate) {
-            listItem.set({scale_x: 0, scale_y: 0});
-            listItem.ease({
-                scale_x: 1,
-                scale_y: 1,
-                duration: MESSAGE_ANIMATION_TIME,
-                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-            });
-        }
+        const duration = animate ? MESSAGE_ANIMATION_TIME : 0;
+        listItem.set({scale_x: 0, scale_y: 0});
+        listItem.ease({
+            scale_x: 1,
+            scale_y: 1,
+            duration,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
     }
 
     moveMessage(message, index, animate) {
@@ -702,21 +692,17 @@ export const MessageListSection = GObject.registerClass({
                 this._list;
         }
 
-        if (animate) {
-            listItem.ease({
-                scale_x: 0,
-                scale_y: 0,
-                duration: MESSAGE_ANIMATION_TIME,
-                mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-                onComplete: () => {
-                    listItem.destroy();
-                    nextMessage?.grab_key_focus();
-                },
-            });
-        } else {
-            listItem.destroy();
-            nextMessage?.grab_key_focus();
-        }
+        const duration = animate ? MESSAGE_ANIMATION_TIME : 0;
+        listItem.ease({
+            scale_x: 0,
+            scale_y: 0,
+            duration,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => {
+                listItem.destroy();
+                nextMessage?.grab_key_focus();
+            },
+        });
     }
 
     clear() {